package com.hospital.controller;


import com.hospital.domain.Doctor;
import com.hospital.service.DoctorService;
import com.hospital.service.impl.DoctorServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/doctors")
public class DoctorController {

    @Autowired
    DoctorService doctorService;

    @PostMapping("/login")
    public Result login(@RequestBody Doctor doctor, HttpServletRequest request, HttpServletResponse response){
        return doctorService.login(doctor,request,response);

    }

    @GetMapping("/selectRate")
    Integer selectRate(String doctorNum){
        return doctorService.selectRate(doctorNum);
    }

    @PostMapping("/selectDoctor")
    Doctor selectDoctor(HttpSession session){
        int doctorID = (int)session.getAttribute("doctorID");
        return doctorService.selectDoctorByDoctorID(doctorID);
    }
}
